import { request } from "../../request/index.js";
import regeneratorRuntime from '../../lib/runtime/runtime';
import { login } from "../../utils/asyncWx.js";

Page({
  //获取用户信息
   
  
  // async handleGetUserInfo(e) {
  //   try {
      
  //     let token="Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjIzLCJpYXQiOjE1NjQ3MzAwNzksImV4cCI6MTAwMTU2NDczMDA3OH0.YPt-XeLnjV-_1ITaXGY2FhxmCe4NvXuRnRB8OMCfnPo";
  //     wx.setStorageSync("token", token);
  //     wx.navigateBack({
  //       delta: 1
  //     });
  
  //   } catch (error) {
  //     console.log(error);
  //   }
  // }
     getUserProfile(e) {
    // 推荐使用wx.getUserProfile获取用户信息，开发者每次通过该接口获取用户个人信息均需用户确认
    // 开发者妥善保管用户快速填写的头像昵称，避免重复弹窗
try {
  wx.getUserProfile({
    desc: '用于完善会员资料', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
    success: (res) => {
      console.log(res);
       // 1 获取用户信息
  let token="Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjIzLCJpYXQiOjE1NjQ3MzAwNzksImV4cCI6MTAwMTU2NDczMDA3OH0.YPt-XeLnjV-_1ITaXGY2FhxmCe4NvXuRnRB8OMCfnPo";
  wx.setStorageSync("token", token);
  console.log(token);
  wx.navigateBack({
    delta: 1
  });
  
      this.setData({
        userInfo: res.userInfo,
        hasUserInfo: true
      })
    }
  })
} catch (error) {
  console.log(error);
}
  }
})
